package models

import (
	"database/sql"
	"time"
)

const UserJwtSecret = "secret"
const UserJwtDuration = 5184000

type User struct {
	ID        int       `gorm:"primarykey"`
	Name      string    `gorm:"column:name;comment:用户名;not null;unique"`
	NickName  string    `gorm:"column:nick_name;comment:昵称"`
	PassWord  string    `gorm:"column:password;comment:密码"`
	Tel       string    `gorm:"column:tel;comment:手机号"`
	Avatar    string    `gorm:"column:avatar;comment:头像"`
	RoleType  uint8     `gorm:"column:role_type;comment:角色类型;default:1"`
	Duration  int       `gorm:"column:duration;comment:时长;default:0"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type UserToken struct {
	Token          string       `gorm:"type:varchar(4095);" json:"token"`
	TokenCreatedAt sql.NullTime `gorm:"column:token_created_at" json:"token_created_at"`
}

func (e *User) TableName() string {
	return "users"
}
